package com.slfx.collections.map;

import org.junit.Test;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 * @author ：slfx
 * @date：2019/7/5
 * @version: V1.0
 * @slogan:天下风云出我辈，一入代码岁月催
 * description：
 */
public class MapDeadLock {

    public static void main(String[] args) {
        for (int i=0;i<10;i++){
            new Thread(new MultiThread()).start();
        }
    }

    @Test
    public  void test(){
        HashMap<Integer, Integer> hashMap = new HashMap<>();
        int j=0;
        for (int i = 0; i < 9; i++) {
            hashMap.put(j,i);
            j=j+16;
        }
        System.out.println(hashMap);
    }

    @Test
    public  void test2(){
        Map<Integer, Integer> hashMap = new ConcurrentHashMap<>();
        int j=0;
        for (int i = 0; i < 9; i++) {
            hashMap.put(j,i);
            j=j+16;
        }
        System.out.println(hashMap);
    }
}
